<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      Promise.resolve()
        .then(() => {
          console.log(1);
          return Promise.resolve();
        })
        .then(() => {
          console.log(2);
          return Promise.reject(new Error());
        })
        .then(() => {
          console.log(3);
          return Promise.resolve();
        })
        .then(() => {
          console.log(4);
          return Promise.resolve();
        });
      // .catch((err) => {
      //   console.log(err);
      // });

      window.addEventListener("unhandledrejection", (event) => {
        console.log(event.reason);
      });
    </script>
  </body>
</html>
